﻿@model IEnumerable<Developer.Entity.BookTypes>
@{
    ViewBag.Title = "Index";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
    int i = 1;
}
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 图书管理 <span class="c-gray en">&gt;</span> 类型列表 <a class="btn btn-success radius r" id="btn-refresh" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="text-c">
        <form id="searchForm" action="/admin/mybook/BookType" method="get">
            <input type="text" class="input-text" style="width: 250px" placeholder="输入类型关键字" id="username" name="name" value="@ViewBag.Name">
            <button type="submit" class="btn btn-success radius"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
        </form>
    </div>
    <div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"><a href="javascript:;" onclick="sf_show('添加类型', '/admin/mybook/edittype', '', '420',true)" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加类型</a> </span> <span class="r">共有数据：<strong>@ViewBag.itemCount</strong> 条</span> </div>
    <div class="mt-20">
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
                <tr class="text-c">
                    <th><input type="checkbox" name="" value=""></th>
                    <th>序号</th>
                    <th>名称</th>
                    
                    <th>创建时间</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model)
                {
                    <tr class="text-c">
                        <td><input type="checkbox" value="@item.Id" name="checkedList"></td>
                        <td id="companyId">@(i++)</td>
                        <td>@item.Name</td>
                        <td>@item.CreateTime</td>
                       
                        <td class="td-manage">
                            <a title="修改" href="javascript:;" id="setVip" onclick="sf_show('修改','/admin/mybook/Edit/?type=@(item.Id)','','420',true)" class="ml-5 btn btn-primary radius" style="text-decoration: none">修改</a>
                            <a title="删除" href="javascript:;" id="down" onclick="deletetype(@item.Id);" class="ml-5 btn btn-primary radius" style="text-decoration: none">删除</a>
                            <a title="下架" href="javascript:;" id="down" onclick="downtype(@item.Id);" class="ml-5 btn btn-primary radius" style="text-decoration: none">下架</a>
                        </td>
                    </tr>
                }
            </tbody>
        </table>
        <div id="adminPage"></div>
        <div style="clear:both;"></div>
    </div>
</div>
<script type="text/javascript">
    sf_page('adminPage', @ViewBag.pageCount);
    $(function() {
        $("#setVip")
            .click(function() {
                var isVip = $(this).parents("tr").find("td:eq(4)").text();
                var userId=$(this).parents("tr").find("input").val();
                console.log(isVip);
                if (isVip == "已完结") {
                    layer.confirm("确认要把此订单设置为未完结状态吗？",
                        function() {
                            self.location = "/admin/order/SetOrderDone?Id=" + userId;
                        });
                } else {
                    layer.confirm("确认确认要把此订单设置为已完结状态吗？",
                        function() {
                            self.location = "/admin/order/SetOrderDone?Id=" + userId;
                        });
                }
            });
    });
    function deletetype(bid) {
        layer.confirm("删除该分类？确保该分类下无图书",
            function () {
                $.ajax({
                    url: '/admin/mybook/deletetype',
                    dataType: 'Json',
                    type: 'POST',
                    data: { 'tid': bid },
                    success: function (data) {
                        layer.confirm(data["success"],
                            function () {
                                self.location = "/admin/mybook/index";
                            });
                    }
                });
            });
    }
    function downtype(bid) {
        layer.confirm("将下架该分类中所有图书，确认操作？",
            function () {
                $.ajax({
                    url: '/admin/mybook/downtype',
                    dataType: 'Json',
                    type: 'POST',
                    data: { 'tid': bid },
                    success: function (data) {
                        layer.confirm("已全部下架",
                            function () {
                                self.location = "/admin/mybook/index";
                            });
                    }
                });
            });
    }
</script>
